package com.ganee.agora.adapter

import android.text.TextUtils
import android.widget.ImageView
import android.widget.TextView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.bitmap.CenterCrop
import com.chad.library.adapter.base.BaseQuickAdapter
import com.ganee.agora.R
import com.ganee.agora.manager.RecyclerViewHolder
import com.ganee.agora.model.HomeListBean
import com.ganee.baselib.widget.image.transform.GlideRoundTransform
import com.ganee.baselib.mvvmlibrary.widget.loadingdrawable.DensityUtil
import com.ganee.agora.manager.RoundedCornersTransform
import com.ganee.agora.model.InsertActivityEntity
import com.ganee.agora.widget.ratingbar.AndRatingBar


/**
 *    @author : EricCui
 *    date   : 2020-01-01 17:52
 *    desc   : 详情推荐列表adapter
 */

class DetailRecommendAdapter (entityList: MutableList<InsertActivityEntity>) : BaseQuickAdapter<InsertActivityEntity,
        RecyclerViewHolder>(R.layout.item_recyclerview_detail_recommend,entityList){


    override fun convert(helper: RecyclerViewHolder, item: InsertActivityEntity?) {
        if (item != null){
            val icon = helper.getView<ImageView>(R.id.detail_also_view_iv_pic) as ImageView
            Glide.with(mContext)
                    .load(item.activePic)
                    .transform(GlideRoundTransform(mContext))
                    .diskCacheStrategy(DiskCacheStrategy.NONE)
                    .placeholder(R.drawable.home_placeholder)
                    .error(R.drawable.home_placeholder)
                    .into(icon)
            helper.setText(R.id.detail_also_view_tv_title,item.eventTitle)
            val ratingBar = helper.getView<AndRatingBar>(R.id.detail_also_view_ratingbar) as AndRatingBar
            if (!TextUtils.isEmpty(item.score)) {
                ratingBar.rating = item.score!!.toFloat()
            }
        }
    }

}